package com.fengkai.filepost.pdfoutstream.test.my;

import java.util.Scanner;

/**
 * @author Fengkai
 * @creat 2023/5/5
 * 找出重复代码
 */
public class SameCode {
    public static void main (String[] args) {
        //private_void_method
        //public_void_method
        System.out.println(getSameCode("private_void_method", "public_void_method"));
    }


    private static String getSameCode(String t1, String t2) {
        //暴力循环吧
        String resutl = "";
        int length = t1.length();
        for (int i = 0; i < length; i++) {
            for (int j = length; j >= i ; j--) {
                String substring = t1.substring(i, j);
                if (t2.contains(substring)){
                    if (substring.length() > resutl.length()){
                        resutl = substring;
                    }
                }
            }
        }
        return resutl;
    }
}
